<?php
require_once 'lib/BaseModel.php';

class Perms extends Tamtay_Table_Abstract
{
	protected $_name = 'mytt_role_permission';
	protected $_primary = 'rid';
	
	public function getUserPermissions($uid, $rids)
	{
        $db = $this->getSlaveDB();
		if (count($rids) == 0){
			return array();
		}                     		
		$in="";
		for ($i = 0; $i < count($rids); $i++)
		{
			if ($in!="")
			{
				$in = $in . ", ";
			}
			$in = $in . $rids[$i];
		}
		$in="(" . $in . ")";
		
		$sql="SELECT DISTINCT p.perm FROM mytt_role r INNER JOIN mytt_role_permission p ON p.rid = r.rid WHERE r.rid IN " . $in;
		return $db->fetchAll($sql);
	}
}

